package leetcode.Y2024M5D27;

import org.junit.Test;

/**
 * 不熟
 */
public class S82 {
    public ListNode deleteDuplicates(ListNode head) {
        ListNode pre = new ListNode(-1);
        pre.next = head;
        ListNode cur = pre;
        while (cur.next != null&&cur.next.next!=null) {
           int val=cur.next.val;
           if (cur.next.next.val==val){
               while (cur.next!=null&&cur.next.val==val){
                   cur.next=cur.next.next;
               }
           }else {
               cur=cur.next;
           }
        }
        return pre.next;
    }

    @Test
    public void test() {
        int[] head = {1, 2, 3, 3, 4, 4, 5};
        ListNode listNode = ListNode.createListNode(head);
        System.out.println(deleteDuplicates(listNode));
    }
}
